﻿<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ page import="java.util.Properties,java.io.FileInputStream"%>
<% 
String realPath = request.getSession().getServletContext().getRealPath("/");
String propPath="";
FileInputStream fis = null;
Properties props = new Properties();
//没有使用框架，从frame.properties中读取
if(session.getAttribute("frame")==null||session.getAttribute("skinName")==null||session.getAttribute("themeColor")==null)
{ 
	propPath = "WEB-INF/prop/frame.properties";
  props=new Properties();
  try {
		fis = new FileInputStream(realPath+propPath);
		props.load(fis);
	} catch (Exception e) {
		throw new RuntimeException(e);
	} finally {
		if(fis!=null){
			try{
				fis.close();
			}
			catch (Exception e) {
				
			}
		}
	}
	//获取frame框架的uri信息
	if(session.getAttribute("frame")==null){
		String frame = props.getProperty("frameUrl","/frame");
		String base = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort();
		session.setAttribute("base",base);
		if(frame.indexOf("http")==-1){
			frame = base + request.getContextPath() +frame;
		}
		session.setAttribute("frame",frame);
	}
	//获取皮肤包的根路径
	if(session.getAttribute("frameBaseUrl")==null){
		String base = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+request.getContextPath();
		session.setAttribute("frameBaseUrl",base);
	}
	//获取工程相对uri地址
	if(session.getAttribute("contextPath")==null){
		String contextPath = request.getContextPath();
		session.setAttribute("contextPath",contextPath);
	}
	//获取libs的绝对uri信息
	if(session.getAttribute("libs")==null){
		String libs = props.getProperty("libsUrl","/libs");
		if(libs.indexOf("http")==-1){
			String base = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort();
			libs = base + request.getContextPath() +libs;
		}
		session.setAttribute("libs",libs);
	}
	//获取皮肤的模板所在目录的绝对uri信息
	if(session.getAttribute("sample")==null){
		String sample = props.getProperty("sample","flat");
		String base = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort();
		session.setAttribute("sample",base + request.getContextPath()+"/sample/"+sample);
	}
	//获取皮肤信息
	if(session.getAttribute("skinName")==null)
	{
		String skinName = props.getProperty("skinName","flatBlue_accordion");
		session.setAttribute("skinName",skinName);
	}
	//获取主题信息
	if(session.getAttribute("themeColor")==null)
	{
		String themeColor =props.getProperty("themeColor","flatBlue");
		session.setAttribute("themeColor",themeColor);
	}
}
%>
